package com.zz.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import nonapi.io.github.classgraph.json.Id;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Update;
import org.hibernate.validator.constraints.Range;
import org.springframework.data.elasticsearch.annotations.Document;

import javax.validation.constraints.Future;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;

/**
 * 活动信息
 * @author zhouzi
 */
@Data
@Document(indexName="activity")//索引名称，建议与实体类一致
@ApiModel("活动信息")
public class Activity implements Serializable {
    private static final long serialVersionUID = 1L;


    @ApiModelProperty("主键")
    @TableId(type= IdType.AUTO)//主键自增
    @NotNull(message = "活动id不能为空",groups = {Update.class, Delete.class})
    private Integer id;

    //@Id
    @ApiModelProperty("社团编码")
    //@JSONField(serializeUsing = ToStringSerializer.class)
    @NotNull(message = "社团编码不能为空")
    private Integer clubId;


    @ApiModelProperty("负责人学号")
    @NotNull(message = "负责人学号不能为空")
    @Range(min = 1000000000, message = "负责人学号为10位")
    private Integer leaderId;

    //活动名称
    @ApiModelProperty("活动名称")
    @NotNull(message = "活动名称不能为空", groups = {Insert.class, Update.class})
    private String name;

    /**
    * @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    * 此注释作用是，出参时，自动把Date型对象数据转化成格式化后的字符串输出: yyyy-MM-dd HH:mm:ss
    * */
    @ApiModelProperty("活动时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @NotNull(message = "活动时间不能为空", groups = {Insert.class, Update.class})
    @Future
    private Date time;


    @ApiModelProperty("活动地点")
    @NotNull(message = "活动地点不能为空", groups = {Insert.class, Update.class})
    private String place;


    @ApiModelProperty("预期人数")
    @NotNull(message = "预期人数不能为空", groups = {Insert.class, Update.class})
    private Integer number;


    @ApiModelProperty("已参加人数")
    @NotNull(message = "已参加人数不能为空")
    private Integer attendedNumber;


    @ApiModelProperty("操作")
    private Integer operate;//0 不通过 1 通过


    @ApiModelProperty("状态码")
    private Integer status;//0 未审核 1 已审核


    @ApiModelProperty("是否申请")
    private Integer apply;//0 未申请 1 已申请



    @ApiModelProperty("申请时间")
    @TableField(fill = FieldFill.INSERT_UPDATE)//社团提交活动申请时,自动填入当前时间
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date registerTime;

    @ApiModelProperty("活动简介")
    @NotNull(message = "活动简介不能为空", groups = {Insert.class, Update.class})
    private String introduce;

    @ApiModelProperty("图片路径")
    private String image;
}
